import { BaseWindow } from "../../../../component/window/BaseWindow";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { PlayerMiniInfo } from "../../../model/PlayerMiniInfo";
import { FriendInfo } from "../../../model/FriendInfo";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { StringHelper } from "../../../../../com/gengine/utils/StringHelper";
import { MsgManager } from "../../../manager/MsgManager";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GTextInput } from "../../../../../com/mui/controls/GTextInput";
type int = number;
//class MoveToBlackAlertWindow
    
    export  class MoveToBlackAlertWindow extends BaseWindow
    {
        constructor()
        {
            super();
            if (MoveToBlackAlertWindow._instance) 
            {
                throw new Error("MoveToBlackAlertWindow单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.setSize(310, 200);
            this.titleHeight = 28;
            this.title = Language.getString(54164);
            this._bg = ObjCreate.createBg(17, 39, 274, 128, this);
            this._tipTxt = ObjCreate.createTextField("", 0, 50, 300, 50, this, new GTextFormat(FontUtil.songtiName, 14, 11661311));
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._inputTipTxt = ObjCreate.createTextField("", 0, 80, 300, 50, this, new GTextFormat(FontUtil.songtiName, 14, 11661311));
            this._inputTipTxt.multiline = true;
            this._inputTipTxt.htmlText = "<textFormat leading=\'5\'>" + HTMLUtil.addColor(Language.getString(40382), "#B1efff") + "</textFormat>";
            this._inputTipTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._delInput = ObjCreate.createGTextInput(80, 120, 135, 20, this);
            this._delInput.maxChars = 6;
            this._delInput.restrict = "A-z";
            this._delTxt = ObjCreate.createTextField(Language.getString(40383), 2, 80, 300, 50, this, new GTextFormat(FontUtil.songtiName, 14, 16711680));
            this._delTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._okBtn = ObjCreate.createGButton(Language.getString(54203), 60, 130, 70, 27, this);
            this._okBtn.styleName = "RedButton";
            this._okBtn.name = "ok";
            this._cancelBtn = ObjCreate.createGButton(Language.getString(54204), 160, 130, 70, 27, this);
            this._cancelBtn.name = "cancel";
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            this._cancelBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        public set playerMiniInfo(arg1: PlayerMiniInfo)
        {
            this._playerMiniInfo = arg1;
            return;
        }

        public MoveToBlackAlertWindow.get playerMiniInfo(): PlayerMiniInfo
        {
            return this._playerMiniInfo;
        }

        public set friendInfo(arg1: FriendInfo)
        {
            this._friendInfo = arg1;
            return;
        }

        public MoveToBlackAlertWindow.get friendInfo(): FriendInfo
        {
            return this._friendInfo;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc2=null;
            var loc1=arg1.target as GButton;
            if (this._playerMiniInfo) 
            {
                if (loc1.name != "ok") 
                {
                    this.hide();
                }
                else 
                {
                    if (this._mode == MoveToBlackAlertWindow.ValidateMode) 
                    {
                        loc2 = this._delInput.text.toLocaleLowerCase();
                        if (StringHelper.getCharLength(StringHelper.trim(loc2)) == 0 || !(loc2 == "delete")) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(40386));
                            return;
                        }
                    }
                    if (this._type != MoveToBlackAlertWindow.Del) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.FriendMoveToBlackList, this._playerMiniInfo));
                    }
                    else 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.FriendDelete, this._friendInfo));
                    }
                    this.hide();
                }
            }
            return;
        }

        public setMode(arg1: int, arg2: int): void
        {
            this._mode = arg1;
            this._type = arg2;
            if (arg1 != MoveToBlackAlertWindow.NormalMode) 
            {
                this.setSize(310, 220);
                this._bg.height = 168;
                this._okBtn.y = 170;
                this._cancelBtn.y = 170;
                this._delTxt.y = 150;
                this._inputTipTxt.visible = true;
                this._delInput.visible = true;
            }
            else 
            {
                this.setSize(300, 180);
                this._bg.height = 128;
                this._okBtn.y = 130;
                this._cancelBtn.y = 130;
                this._delTxt.y = 80;
                this._inputTipTxt.visible = false;
                this._delInput.visible = false;
            }
            if (arg2 != MoveToBlackAlertWindow.Del) 
            {
                this._tip = Language.getStringByParam(40384, this._playerMiniInfo.playerName);
            }
            else 
            {
                this._tip = Language.getStringByParam(40385, this._playerMiniInfo.playerName);
            }
            this._tipTxt.htmlText = this._tip;
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this._playerMiniInfo = null;
            this._friendInfo = null;
            this._delInput.text = "";
            return;
        }

        public static get instance(): MoveToBlackAlertWindow
        {
            if (MoveToBlackAlertWindow._instance == null) 
            {
                MoveToBlackAlertWindow._instance = new MoveToBlackAlertWindow();
            }
            return MoveToBlackAlertWindow._instance;
        }

        /* internal */ /* var */_mode: int;

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_cancelBtn: GButton;

        /* internal */ /* var */_delInput: GTextInput;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_inputTipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_delTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_tip: string="";

        /* internal */ /* var */_playerMiniInfo: PlayerMiniInfo;

        /* internal */ /* var */_friendInfo: FriendInfo;

        /* internal */ /* var */_type: int;

        public static /* var */NormalMode: int=0;

        public static /* var */ValidateMode: int=1;

        public static /* var */Del: int=0;

        public static /* var */MoveToBlack: int=1;

        /* internal */ static /* var */_instance: MoveToBlackAlertWindow;
    }

            MoveToBlackAlertWindow.NormalMode = 0;
            MoveToBlackAlertWindow.ValidateMode = 1;
            MoveToBlackAlertWindow.Del = 0;
            MoveToBlackAlertWindow.MoveToBlack = 1;
        